package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 酒店控制层
 *
 * @Name : HotelController
 * @Author : WuQiang
 * @Date : 2022-09-19 16:54
 * @Description : 酒店控制层
 */
@RestController
@RequestMapping("/hotel")
public class HotelController {

    @Autowired
    private IHotelService hotelService;

    /**
     * 搜索
     *
     * @param requestParams 请求参数
     * @return {@code PageResult}
     */
    @PostMapping("/list")
    public PageResult search(@RequestBody RequestParams requestParams) {
        return hotelService.getList(requestParams);
    }


    /**
     * 过滤器
     *
     * @param requestParams 请求参数
     * @return {@code Map<String, List<String>>}
     */
    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody RequestParams requestParams) {
        return hotelService.filters(requestParams);
    }


    /**
     * 自动补全
     *
     * @param key 搜索字段
     * @return {@code List<String>}
     */
    @GetMapping("/suggestion")
    public List<String> getSuggestion(@RequestParam("key") String key) {
        return hotelService.getSuggestion(key);
    }
}
